package com.property.manage.service.system;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.property.manage.dao.system.SysSetMapper;
import com.property.manage.model.system.SysSet;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 描述
 *
 * @author lwb
 * @since 2020/7/16
 */
@Component
@AllArgsConstructor
public class SysSetService {

    private SysSetMapper sysSetMapper;

    public List<SysSet> getSysSets(String type){
        QueryWrapper<SysSet> wrapper = new QueryWrapper<>();
        wrapper.eq("type", type);
        return sysSetMapper.selectList(wrapper);
    }

    public SysSet getSysSet(Integer id){
        return sysSetMapper.selectById(id);
    }

    public String getDesc(String type,String value){
        QueryWrapper<SysSet> qw=new QueryWrapper<>();
        qw.eq("type",type);
        qw.eq("value",value);
        SysSet sysSet = sysSetMapper.selectOne(qw);
        if (sysSet==null){
            return null;
        }
        return sysSet.getDesc();
    }
}
